C Program
Write C Program To Print Multiplication Table using For Loop
Examples :-
#include<stdio.h>
void main()
{
int n,i;
printf("Enter Any Number:");
scanf("%d",&n);
for(i=1;i<=10;i++)
printf("%d\t",i*n);
}
Explain Program
Step :1
#include<stdio.h>
Standard
Input/Output
header file.
Step :2
void main()
defines the main function which is the entry
point of any C program.
Step :3
int n, i;
- n:
to store the number entered by the user.
- i:
loop control variable for the for loop.
Step :4
printf("Enter Any Number:");
Prints
a message to the screen to the user to enter a number
Step :5
scanf("%d", &n);
- input
from the user and stores it in the variable n.
- %d
is used to read an integer.
- &n
means the address of n, because scanf needs to modify the variable.
Step :6
for(i = 1; i <= 10; i++)
- A for
loop that runs from i = 1 to i = 10.
- Purpose:
to generate and display the multiplication table of the number n
Step :7
printf("%d\t", i * n);
- In
each iteration, prints i * n (which is a multiplication result).
- \t
is a tab character, used to separate the numbers with space.
Write C Program To Print Multiplication Table using For Loop
Program Output
Related Post :-
Comments
Post a Comment